package strategy;

import java.sql.*;

public class JDBCHelper {

    private DatabaseStrategy strategy;

    public JDBCHelper(DatabaseStrategy strategy) throws ClassNotFoundException {
        this.strategy = strategy;
        strategy.loadDriver();
    }

    public Connection getConnection() throws SQLException {
        String url = strategy.generateURL();
        return DriverManager.getConnection(url);
    }

    public String format(Object value) {
        return strategy.format(value);
    }

    public String format(boolean value) {
        return format(new Boolean(value));
    }

    public String format(int value) {
        return format(new Integer(value));
    }
}
